package com.example.demo.service;

import com.example.demo.mapper.CourseMapper;
import com.example.demo.mapper.LoginMapper;
import com.example.demo.vo.Course;
import com.example.demo.vo.Login;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Random;

/**
 * @author ：hantao
 * @date ：Created in 2024/12/26 10:38
 * @description：
 */
@Service
public class UserService {
	@Autowired
	private LoginMapper loginMapper;

	@Autowired
	private CourseMapper courseMapper;

	@Autowired
	private CourseService courseService;
	public String getUserName() {
		List<Login> login = loginMapper.getLogin();
		System.out.println(login);
		return "hantao";
	}

	@Transactional
	public void addUser(Login login) {
		loginMapper.addLogin(login);
		Course course = new Course();
		Random random = new Random();
		//输入一个随机数100-1000之内
		course.setCouId(random.nextInt(900)+100);
		course.setCouName("java");
		course.setMajor("1");
		courseMapper.addCourse(course);
		System.out.println("!23");
		//int i = 1/0;
	}
}
